//
//  ReadyGoView.m
//  NewGame
//
//  Created by wwj on 15/10/13.
//  Copyright © 2015年 wwj. All rights reserved.
//

#import "ReadyGoView.h"
#import "SoundTool.h"

@implementation ReadyGoView

-(void)setFrame:(CGRect)frame{
    frame = CGRectMake(47, 172, 280, 95);
    [super setFrame:frame];
}

+(instancetype)readyGoView{
    return [[[NSBundle mainBundle] loadNibNamed:@"ReadyGoView" owner:nil options:nil] firstObject];
}

-(void)beginWithBlock:(ReadyGoBlock)readyGoBlock{
    
    if (readyGoBlock == nil) return;
    
    self.hidden = NO;
    self.transform = CGAffineTransformMakeTranslation(400, 0);
    
    [[SoundTool sharedSoundTool] playSound:kSoundReadyGo];
    
    [UIView animateWithDuration:0.3 animations:^{
        self.transform = CGAffineTransformIdentity;
    }completion:^(BOOL finished) {
        self.image = [UIImage imageNamed:@"go"];
        [UIView animateWithDuration:0.3 delay:0.5 options:UIViewAnimationOptionCurveEaseOut  animations:^{
            self.transform = CGAffineTransformMakeTranslation(-400, 0);
        }completion:^(BOOL finished) {
            self.hidden = YES;
             readyGoBlock();
        }];
    }];
}

@end
